<?php
defined("_VALID_ACCESS") || die('Direct access forbidden');
    class Eyeworx_Inventory_LensInstall extends ModuleInstall {

        public function install() {
            try {
                $type = array(
                    'single'=>'Single Vision/Bifocal',
                    'double'=>'Double Vision/Multifocal',
                    'prog'=>'Progressive',
                    'asph'=>'Aspheric'
                );
                Utils_CommonDataCommon::new_array('Eyeworx/Inventory/Lens/type', $type);

                $material = array(
                    'cr39'=>'Glass',
                    'plastic'=>'Plastic Lens',
                    'poly'=>'Polycarbonates',
                    'trans'=>'Transitional'
                );
                Utils_CommonDataCommon::new_array('Eyeworx/Inventory/Lens/material', $material);

                $lens_recordset = new Eyeworx_Inventory_Lens_RBO_RBOLenses();
                $lens_recordset->install();
                $lens_recordset->add_default_access();
                $lens_recordset->set_caption('Lens');

                $lens_recordset = new RBO_RecordsetAccessor('eyeworx_lens');
                $lens_recordset->new_addon('Eyeworx/Inventory/Lens','lens_import_addon',array('Eyeworx_Inventory_LensCommon', 'lens_import_addon_label'));
            } catch (Exception $e) {
                return false;
            }
            return true;
        }

        public function uninstall() {
            try {
                $lens_recordset = new Eyeworx_Inventory_Lens_RBO_RBOLenses();
                $lens_recordset->uninstall();

                $lens_recordset = new RBO_RecordsetAccessor('eyeworx_lens');
                $lens_recordset->delete_addon('Eyeworx/Inventory/Lens','lens_import_addon',array('Eyeworx_Inventory_LensCommon', 'lens_import_addon_label'));

                Utils_CommonDataCommon::remove('Eyeworx/Inventory/Lens/type');
                Utils_CommonDataCommon::remove('Eyeworx/Inventory/Lens/material');
            } catch (Exception $e) {
                return false;
            }
            return true;
        }

        public function requires($v) {
            return array(
                array('name'=>'Base/Lang','version'=>0),
                array('name'=>'Utils/RecordBrowser','version'=>0),
            );
        }

        public function info() {
            return array(
                'Author'=>'Velicaria, Maureen D.',
                'Description'=>'Lens'
            );
        }

        public function version() {
            return array('1.0');
        }

        public function simple_setup() {
            return array('package'=>__('Eyeworx'), 'option'=>__('Lens'));
        }

    }
?>